package com.taiyuan.ty.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taiyuan.ty.entity.Place;
import com.taiyuan.ty.mapper.PlaceMapper;
import com.taiyuan.ty.service.PlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class PlaceServiceImpl extends ServiceImpl<PlaceMapper, Place> implements PlaceService {

    @Autowired
    private PlaceMapper placeMapper;

    /**
     * 添加地点
     * @param place 地点实体
     * @return 是否成功
     */
    @Transactional
    public boolean save(Place place) {
        // 插入地点信息
        placeMapper.insert(place);
        return true;
    }

    /**
     * 更新地点信息
     * @param place 地点实体
     * @return 是否成功
     */
    @Transactional
    public boolean update(Place place) {
        placeMapper.updateById(place);
        return true;
    }

    /**
     * 删除地点
     * @param id 地点ID
     * @return 是否成功
     */
    @Transactional
    public boolean delete(Long id) {
        placeMapper.deleteById(id);
        return true;
    }

    /**
     * 根据地点ID查询地点信息
     * @param id
     * @return
     */
    public Place getPlaceById(Long id) {
        return placeMapper.selectById(id);
    }
}